home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 2.2 KB | 52 lines | [TEXT/GEOL] |
- Item 4855308 12-Sept-90 18:39PDT
-
- From: MM.XOBJ MacroMind, XObject Support,PRT
-
- To: CPLUS.DEV$ C++ Interest List--Developers
- CPLUS.APPLE$ C++ Interest List--Apple Employees
-
- cc: D0776 Dragon SW, Alan McNeil,PRT
- D5543 Resonate, Geoff Brown,PRT
- D3431 MacroMind Programmers,PRT
-
- Sub: Definitive virtual inlines?
-
- I think I now have a definitive answer on the Inline vs. Virtual question.
-
- There is no incompatibility between inlines and virtuals. Even though “inline”
- means: resolve the function efficiently at compile time, and “virtual” means:
- defer function resolution till compile time, Lippman [p352] states:
-
- There are three cases in which an invocation of a virtual function is
- resolved statically at compile time:
-
- 1. When a virtual function is invoked through an object of the class type
- ......
- 2. When a virtual function is explicitly invoked through a pointer or
- reference using the class scope operator. ....
-
- 3. When a virtual function is invoked within either the constructor or the
- destructor of a base class. ....
-
- I conclude you won't die and go to hell if you use virtual inlines. Code
- generation bears this out. You will get inlines under the three conditions
- mentioned above. You will get virtuals under all other circumstances. This
- means that despite the bad rap value based objects have in some circles (with
- overhead of implied temporaries and redundant construction/destruction), they
- are very attractive in that you can remain “pure” using virtuals for just about
- everything, and pay no calling penalty for using objects instead of object
- references.
-
- Someone reported a bug due to the use of a virtual inline. I would very much
- like to see an example the problem.
-
- Haim Zamir
- MacroMind, Inc.
- AppleLink MM.XOBJ
-
- P.S. Static resolution in case three isn't strictly necessary, since the
- VTable pointer in the object physically “evolves” during construction, and
- “devolves” during destruction. This prevents any possibility of accessing
- methods of partially constructed or destructed objects.
-
-